<template>
	<view class="boxes" :class="themeName">
		<view class="flex bg box md">
			<view>审核备注</view>
			<input v-model="audit_remark" placeholder="请输入审核备注" type="text" />
		</view>
		<view class="flex bg box md" v-if="stu==2">
			<view>转账说明</view>
			<input v-model="transfer_remark" placeholder="请输入转账说明" type="text" />
		</view>
		<view class="bg box bordernone md" v-if="stu==2">
			<view>转账凭证</view>
			<image @click="uploadFile" class="addimg m-t-30" :src="imgs" mode=""></image>
		</view>
		
		<view @click="submit" class="other-button" hover-class="other-button-hover">
			{{stu==2?'通过':'拒绝'}}
		</view>
	</view>
</template>

<script>
	import { baseimgURL } from "@/config/app";
	import {
		uploadFile
	} from '@/utils/tools';
	import {
	    tixianShenhe
	} from '@/api/others';
export default {
	data() {
		return {
			id:'',
			stu:'',
			type:'',
			audit_remark:'',//审核备注
			transfer_voucher:'',//转账凭证 提现银行卡必填
			transfer_remark:'',//转账说明
			imgs:'../../static/add.png'
		};
	},
	onLoad(options) {
		this.stu = options.stu;
		this.id = options.id;
		this.type = options.type;
	},
	methods: {
		// 上传图片
		async uploadFile() {
			const [error, success] = await uni.chooseImage({
				count: 1
			})
			if (error) {
				return
			}
			uni.showLoading({
				title: '上传中...'
			})
			try {
				const file = await uploadFile(success.tempFilePaths[0])
				this.imgs = file.uri;
				uni.hideLoading()
			} catch (e) {
				this.$toast({
					title: '上传失败，请稍后再试'
				})
				uni.hideLoading()
			}
		
		},
		
		submit(){
			let image = '';
			if(this.stu == 2 && (this.type==3 || this.type==4 || this.type==5)){
				if (!this.audit_remark) return this.$toast({
				    title: '请填写审核备注'
				});
				if (!this.transfer_remark) return this.$toast({
				    title: '请填写转账说明'
				});
				if(this.imgs == '../../static/add.png'){
					this.$toast({
						title: '请上传转账凭证 '
					})
					return
				}else{
					image = this.imgs.split(baseimgURL)[1]
				}
			}else{
				if(this.imgs != '../../static/add.png'){
					image = this.imgs.split(baseimgURL)[1]
				}
			}
			tixianShenhe({
			   audit_remark:this.audit_remark,
			   transfer_voucher:image,
			   transfer_remark:this.transfer_remark,
			   id:this.id,
			   status:this.stu,
			}).then(res => {
				this.$toast({
					title: '操作成功'
				})
				setTimeout(function() {
					uni.navigateBack()
				}, 1000);
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.boxes {
	background-color: #fff;
	height: 100vh;
	.box {
		padding: 25rpx 35rpx;
		border-bottom: 1px solid #eee;
		
		input {
			margin-left: 20rpx;
		    flex: 1;
			font-size: $-font-size-md;
		}
	}
	.bordernone {
		border: none;
		.addimg {
			width: 220rpx;
			height: 220rpx;
		}
	}
}
</style>
